<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include  file="/jsps/common/taglibs.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript">
	    
	    //检查表单信息
	    function check_infos(){
	        
	        if(isContainsNull()){
	            return false;
	        }
	        
	        with(document.content_form){
	            
	            //检查用户名
	            if(!isNaN(user_name.value.charAt(0))){
	                alert("用户名不能以数字开头,请检查!");
	                return false;
	            }
	            else if(!/[A-Z|a-z|0-9]{3,15}/.test(user_name.value)){
	                
	                if(user_name.value.length<3||user_name.value.length>15)
	                  alert("用户名的长度范围为3-15,请检查!");
	                else
	                  alert("用户名只能包含字母和数字,请检查!");
	                
	                return false;
	                
	            }
	            
	            //检查密码
	            if(user_pwd.value.length<3||user_pwd.value.length>15){
	                alert("密码的长度范围为3-15,请检查!");
	                return false;
	            }
	            //if(check_pattern(user_pwd.value)){
	            //    alert("用户名只能包含字母和数字,请检查!");
	            //    return false;
	            //}
	            
	            //检查真实姓名
	            if(!/[\u4e00-\u9fa5]{2,10}/.test(user_rel_name.value)){
	                
	                if(user_rel_name.value.length<2||user_rel_name.value.length>10){
	                    alert("真实姓名的长度为2-10,请检查!");
	                }else{
	                    alert("真实姓名必须使用中文书写,请检查!");
	                }
	                return false;
	                
	            }
	            
	            //检查出生日期
	            //if(!/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/.test(user_birthday)){
	            //    alert("日期格式应该为YYYY-MM-DD,请检查!");
	            //    return false;
	            //}
	            
	            //检查电子邮箱
	            //if (user_email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
                //    alert("邮箱格式有误,请检查!");
                //    return false;
                //}
                
	            //检查地址
	            if(user_addr.value.length>100){
	                
	                alert("地址的长度要小于100,请检查!");
	                return false;
	                
	            }
	            
	            //检查邮编
	            if(user_zipcode.value.length!=6||isNaN(user_zipcode.value)){
	            
	                alert("邮编书写有误,请检查!");
	                return false;
	                
	            }
	            
	            document.forms[0].submit();
	            
	        }    
	        
	    }//end check_infos
	    
	    
	    //是否包含空信息
	    function isContainsNull(){
	        
	        with(document.content_form){
	            
	            //检测是否有未填写的信息
	            if(user_name.value==""){
	                alert("用户名不能为空,请检查!");
	                return true;
	            }
	            else if(user_pwd.value==""){
	                alert("密码不能为空,请检查!");
	                return true;
	            }
	            else if(user_rel_name.value==""){
	                alert("真实姓名不能为空,请检查!");
	                return true;
	            }
	            else if(user_birthday.value==""){
	                alert("生日日期不能为空,请检查!");
	                return true;
	            }
	            else if(user_sex.value==""){
	                alert("没有选择性别,请检查!");
	                return true;
	            }
	            else if(user_email.value==""){
	                alert("电子邮箱不能为空,请检查!");
	                return true;
	            }
	            else if(user_phone_code.value==""){
	                alert("联系方式不能为空,请检查!");
	                return true;
	            }
	            else if(user_addr.value==""){
	                alert("居住地址不能为空,请检查!");
	                return true;
	            }
	            else if(user_zipcode.value==""){
	                alert("邮编不能为空,请检查!");
	                return true;
	            }
	        }
	        
	    }
	    
	</script>
	
  </head>
  
  <body>
      <div class="title">
      <h3>添加会员</h3>
      </div>
      <hr/>
      <div class="wrapper">
          <form class="content_form" name="content_form" action="<c:url value="userMgr"/>" method="post">
              <input type="hidden" name="act" value="add"/>
              <div class="wrapper_div">
                  <span>输入用户名:</span>
                  <input type="text" name="user_name"/>
              </div>
              <div class="wrapper_div">
                  <span>输入密码:</span>
                  <input type="password" name="user_pwd"/>
              </div>
              <div class="wrapper_div">
                  <span>确认密码:</span>
                  <input type="password" name="user_pwd2"/>
              </div>
              <div class="wrapper_div">
                  <span>真实姓名:</span>
                  <input type="text" name="user_rel_name"/>
              </div>
              <div class="wrapper_div">
                  <span>出生日期:</span>
                  <input type="text" name="user_birthday"/>
              </div>
              <div class="wrapper_div">
                  <span>性别:</span>
                  <select name="user_sex">
                      <option>=请选择=</option>
                      <option value="0">男</option>
                      <option value="1">女</option>
                  </select>
              </div>
              <div class="wrapper_div">
                  <span>电子邮箱:</span>
                  <input type="text" name="user_email"/>
              </div>
              <div class="wrapper_div">
                  <span>联系方式:</span>
                  <input type="text" name="user_phone_code"/>
              </div>
              <div class="wrapper_div">
                  <span>居住地址:</span>
                  <input type="text" name="user_addr"/>
              </div>
              <div class="wrapper_div">
                  <span>邮编:</span>
                  <input type="text" name="user_zipcode"/>
              </div>
              <div class="wrapper_div">
                  <button onclick="check_infos();">提交</button>
                  <input type="reset" value="重置"/>
              </div>
          </form>
      </div>
  </body>
</html>
